Skip to content

fix(ssr): preserve pinned module transport after #3290 - #3332

Merged
kojiwakayama merged 32 commits into
mainfrom
codex/pr3290-post-merge-fixes
Aug 3, 2026
Merged

fix(ssr): preserve pinned module transport after #3290#3332
kojiwakayama merged 32 commits into
mainfrom
codex/pr3290-post-merge-fixes

Conversation

@kojiwakayama

@kojiwakayama kojiwakayama commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

PR #3290 merged at stale head d37308797daca1018a5181c37a832a10a82d28cd while its review-fix push was still running. This follow-up carries the commits that never reached that PR's GitHub head, plus the fixes that hardened them afterwards. It does not reopen or duplicate the 109-file #3290 change.

The branch contains 11 commits, grouped by theme:

SSR module pinning transport

  • c5da86bdf Keep same-origin SSR module imports on pinned paths — preserve fetchable same-origin SSR module URLs while providing pinned path transport to strict module-server loaders.
  • aecfdcfdc Keep prebundled RSC scripts aligned with pinned module paths — regenerate the checked-in RSC bundles from the committed source.
  • 20283a9af Separate SSR module pinning transports — split the module-server path transport (/_vf_modules/_pins/<key>/..., consumed by the strict MDX loader) from the query transport (?pins=...&ssr=true, consumed by generic guarded fetch).
  • 64237b2bf fix(mdx): validate pinned module path transport — fail closed on mismatched or malformed pin segments before any adapter access (production blocker fix).
  • 33f6e7094 test(modules): remove vacuous fetch assertions — after the transport split the server emits pinned child paths instead of prefetching same-origin children, so the old nested-fetch assertions asserted nothing; replaced with pinned-path emission assertions.

Specifier canonicalization

  • fa31d3ba3 fix(ssr): canonicalize HTTP module specifiers — normalize uppercase HTTP:// and protocol-relative forms so they route through the guarded cache instead of reaching the runtime's unguarded loader.
  • 53e7d2b7b fix(ssr): preserve nested protocol-relative URLs — resolve //host/path imports found inside fetched modules against their parent URL, falling back to the module-server origin.

Trusted identity and credential authority

  • fc2ed317b Keep project env fetch credentials authoritative — set the privileged Authorization/Accept headers after merging optional caller headers so caller input can never override the internal credential.
  • a1227db01 fix(mdx): preserve trusted local project identity — thread server-constructed isLocalProject through the MDX loader path; false/absent selects the restrictive branch.
  • 5872f71dd test(ssr): name local-project loader argument.

Review fixes (post-review)

  • 26350e548 fix(ssr): harden protocol-relative resolution and address review findings —
    • Foreign hosts in protocol-relative specifiers are forced to https:; only the resolution base's own host may keep a plaintext local-dev scheme.
    • Removed the unreachable toCacheableHttpSpecifier path-transport shim from the query-transport consumer.
    • MDXRenderer.loadModuleESM now takes an options object instead of 12 positional parameters.
    • projectEnvFetcherInternals documented as @internal test-only (the header-authority regression is unobservable through the public fetchProjectEnvVars); documented the intentional query/fragment asymmetry in unwrapDependencyPinningPath.

Verification

  • Focused behavioral suites (specifier-resolver, http-cache, project-env fetcher, module-fetcher, module-writer, page-rendering, orchestrator layout, component-loader, RSC render-handler, module-server, url-builder): all passed after the review fixes.
  • Changed-file deno 2.7.7 format, lint, and type checks passed.
  • git diff --check passed.

Follow-ups

  • None outstanding from review; the loadModuleESM options-object refactor flagged as follow-up material was completed in 26350e548.

Summary by CodeRabbit

  • Bug Fixes

    • Improved server-rendered resolution for same-origin and protocol-relative imports.
    • Preserved HTTPS handling for cross-origin module requests.
    • Strengthened validation, caching, and rejection of invalid dependency-pinned modules.
    • Prevented required environment-request headers from being overridden.
  • Improvements

    • Improved local-project rendering across pages, layouts, and streaming content.
    • Updated hydration output with consistent pinned module paths.
  • Tests

    • Expanded coverage for pinning, URL normalization, local rendering, and request headers.

Project environment requests accepted optional HeadersInit input but constructed the request headers with object spread. A Headers instance would not materialize its entries there, and caller-supplied values could replace required credentials when plain objects were used. Clone the optional headers first, then set the required Authorization and Accept values last.

Constraint: Exact-head review requires optional headers not to override required Authorization or Accept and Headers input to work correctly

Rejected: Keep object spread and only filter known optional headers | HeadersInit includes iterable and Headers forms that object spread cannot represent safely

Confidence: high

Scope-risk: narrow

Tested: npx --yes deno@2.7.7 test --no-check --allow-all src/server/project-env/fetcher.test.ts src/server/runtime-handler/project-resolution.test.ts src/proxy/handler.test.ts src/utils/header-identity.test.ts

Tested: npx --yes deno@2.7.7 fmt --check src/server/project-env/fetcher.ts src/server/project-env/fetcher.test.ts src/server/runtime-handler/project-resolution.ts src/server/runtime-handler/project-resolution.test.ts

Tested: npx --yes deno@2.7.7 lint src/server/project-env/fetcher.ts src/server/project-env/fetcher.test.ts src/server/runtime-handler/project-resolution.ts src/server/runtime-handler/project-resolution.test.ts

Tested: npx --yes deno@2.7.7 check src/server/project-env/fetcher.ts src/server/project-env/fetcher.test.ts src/server/runtime-handler/project-resolution.ts src/server/runtime-handler/project-resolution.test.ts

Tested: git diff --check
Static SSR imports for same-origin module URLs were still emitted as absolute HTTP URLs with query pins. Deno resolves those through its module loader, bypassing the local module server path that handles pinned child lookups. Canonicalize the same-origin SSR case to the same path-pinned transport used by browser and computed imports, while leaving foreign origins unchanged.

Constraint: Dependency-pinned module URLs must stay bound to the request snapshot without requiring network fetches for same-origin children
Rejected: Keep absolute same-origin SSR URLs with query pins | Deno module loading bypasses the local request mock and can escape the module-server handler
Confidence: high
Scope-risk: narrow
Tested: npx --yes deno@2.7.7 test --no-check --allow-all src/server/project-env/fetcher.test.ts src/server/runtime-handler/project-resolution.test.ts src/proxy/handler.test.ts src/utils/header-identity.test.ts src/modules/server/module-server.test.ts src/server/services/rsc/endpoints/endpoint-router.test.ts src/transforms/import-rewriter/url-builder.test.ts src/transforms/import-rewriter/__tests__/hydration-parity.test.ts
Tested: npx --yes deno@2.7.7 lint src/server/project-env/fetcher.ts src/server/project-env/fetcher.test.ts src/server/runtime-handler/project-resolution.ts src/server/runtime-handler/project-resolution.test.ts src/transforms/import-rewriter/url-builder.ts src/transforms/import-rewriter/url-builder.test.ts src/transforms/import-rewriter/__tests__/hydration-parity.test.ts src/modules/server/module-server.test.ts
Tested: npx --yes deno@2.7.7 check src/server/project-env/fetcher.ts src/server/project-env/fetcher.test.ts src/server/runtime-handler/project-resolution.ts src/server/runtime-handler/project-resolution.test.ts src/transforms/import-rewriter/url-builder.ts src/transforms/import-rewriter/url-builder.test.ts src/transforms/import-rewriter/__tests__/hydration-parity.test.ts src/modules/server/module-server.test.ts
The SSR module path pinning change alters the client boot bundle. Committing the deterministic generated artifact keeps release builds and pre-push generation clean without broadening runtime behavior.

Constraint: pre-push generation rewrites the checked-in RSC bundle from the clean committed source

Rejected: Restore generated artifact without committing | leaves pre-push dirty and hides the source-artifact mismatch

Confidence: high

Scope-risk: narrow

Tested: deno task generate

Not-tested: full test suite in this commit step
Generic HTTP cache fetches need same-origin SSR imports to remain absolute URLs carrying query pinning, while module-server loaders need the pinned path transport for strict release lookup. Splitting the helper preserves both contracts and forwards local-project identity through the MDX loader path.

Constraint: guarded HTTP fetch cannot consume root-relative module-server paths

Rejected: Use pinned paths for every SSR caller | breaks generic HTTP cache fetch with Invalid URL

Confidence: high

Scope-risk: moderate

Tested: DENO_TESTING=1 VF_DISABLE_LRU_INTERVAL=1 SSR_TRANSFORM_PER_PROJECT_LIMIT=0 REVALIDATION_PER_PROJECT_LIMIT=0 NODE_ENV=production LOG_FORMAT=text deno test --preload=src/schemas/_test-setup.ts --no-check --allow-all --unstable-worker-options --unstable-net src/server/project-env/fetcher.test.ts src/transforms/import-rewriter/url-builder.test.ts src/transforms/esm/http-cache.test.ts src/transforms/mdx/esm-module-loader/module-writer.test.ts src/transforms/import-rewriter/__tests__/hydration-parity.test.ts src/modules/server/module-server.test.ts

Tested: git diff --check

Tested: deno fmt --check

Tested: deno lint

Tested: deno task typecheck
@kojiwakayama
kojiwakayama requested a review from kwakayama as a code owner August 3, 2026 12:37
Copilot AI review requested due to automatic review settings August 3, 2026 12:37
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@kojiwakayama, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 46 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f83ae4cf-272a-4fc5-ae71-c600a4bb25b6

📥 Commits

Reviewing files that changed from the base of the PR and between c2562b3 and ae24ffc.

⛔ Files ignored due to path filters (1)
  • src/server/services/rsc/endpoints/rsc-bundles.generated.ts is excluded by !**/*.generated.*
📒 Files selected for processing (7)
  • src/modules/import-map/preloader.test.ts
  • src/rendering/orchestrator/layout.test.ts
  • src/transforms/esm/http-cache.test.ts
  • src/transforms/esm/specifier-resolver.ts
  • src/transforms/mdx/esm-module-loader/module-writer.test.ts
  • src/transforms/mdx/index.test.ts
  • tests/integration/server/dev-server.test.ts
📝 Walkthrough

Walkthrough

The change propagates isLocalProject through rendering, RSC, layouts, and MDX loading. It adds an options-object MDX loader API with positional compatibility. SSR pinning uses path keys, HTTP specifiers are canonicalized, and environment request headers are authoritative.

Changes

MDX rendering and module resolution

Layer / File(s) Summary
SSR pinning and HTTP specifier handling
src/transforms/esm/*, src/transforms/import-rewriter/*, src/modules/server/module-server.test.ts
HTTP and protocol-relative specifiers are canonicalized. SSR same-origin imports use path-based dependency pins.
Pinned module transport validation
src/transforms/mdx/esm-module-loader/module-fetcher/*
Pinned paths are unwrapped and validated against dependency snapshots before adapter access.
Structured MDX loading options
src/transforms/mdx/index.ts, src/transforms/mdx/esm-module-loader/*, src/rendering/layouts/utils/component-loader.ts, tests/integration/transforms/mdx/mdx-renderer.test.ts
MDX loading accepts an options object, preserves positional compatibility, and forwards loader context.
Local-project propagation through rendering
src/rendering/orchestrator/*, src/rendering/page-renderer.ts, src/rendering/page-rendering.ts, src/rendering/layouts/*, src/rendering/renderer.ts, src/rendering/factories/*, src/rendering/page-rendering.test.ts, src/rendering/orchestrator/layout.test.ts
Rendering components normalize and forward isLocalProject to page and layout MDX loading.
RSC local-project wiring and tests
src/server/services/rsc/orchestrators/*
RSC handler configuration forwards isLocalProject into render-handler module options. Tests verify the propagation.

Project environment request headers

Layer / File(s) Summary
Environment fetch header authority
src/server/project-env/fetcher.ts, src/server/project-env/fetcher.test.ts
Optional headers are merged before authoritative authorization and JSON accept headers are set. Tests verify the required values.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RenderContext
  participant PageRenderer
  participant LayoutOrchestrator
  participant MDXRenderer
  participant ESMLoader
  RenderContext->>PageRenderer: Pass isLocalProject
  RenderContext->>LayoutOrchestrator: Pass isLocalProject
  PageRenderer->>MDXRenderer: Load page with options object
  LayoutOrchestrator->>MDXRenderer: Load layout with options object
  MDXRenderer->>ESMLoader: Forward local-project and pinning context
Loading

Possibly related PRs

Suggested reviewers: kwakayama, copilot

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 34.38% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the SSR fix for preserving pinned module transport, which matches the pull request's primary changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/pr3290-post-merge-fixes

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This follow-up PR restores/extends SSR dependency-pinning transport behavior that was intended to land after #3290, and updates MDX + import rewriting paths to carry the correct identity and pinning signals through SSR module loading.

Changes:

  • Adds an SSR “path key” pinning helper (appendSameOriginSSRDependencyPinningPathKey) and updates SSR import rewriting/tests to prefer pinned /_vf_modules/_pins/... transport where required.
  • Plumbs isLocalProject through the MDX ESM loader context so local-only HTTP fallbacks can be gated correctly.
  • Makes project-environment fetch headers (Authorization, Accept) authoritative over optional caller-provided headers, with a targeted test.

Verification (from PR description):

  • Focused behavioral suite passed (10 tests, 263 steps).
  • Format/lint/type checks passed; pre-push gate mostly green with one unrelated flaky test that passed in isolation.
  • I did not run commands in this review environment; safest next step is to rerun the focused suites touching MDX/module loading and SSR module rewrite paths.

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/transforms/mdx/index.ts Adds isLocalProject parameter and forwards it into the MDX ESM loader context.
src/transforms/mdx/esm-module-loader/types.ts Extends ESMLoaderContext with isLocalProject.
src/transforms/mdx/esm-module-loader/loader-helpers.ts Propagates isLocalProject into VF module import processing context.
src/transforms/mdx/esm-module-loader/import-transformer.ts Switches SSR same-origin pinning to use the new path-key helper.
src/transforms/mdx/esm-module-loader/module-writer.test.ts Updates MDX module cache identity test to understand path-key pinning transport and passes isLocalProject.
src/transforms/import-rewriter/url-builder.ts Implements appendSameOriginSSRDependencyPinningPathKey and adjusts SSR query pinning helper behavior.
src/transforms/import-rewriter/url-builder.test.ts Adds coverage for SSR query pinning vs SSR path-key pinning behavior.
src/transforms/import-rewriter/core.ts Updates SSR target rewrite behavior to use the SSR path-key helper.
src/transforms/import-rewriter/tests/hydration-parity.test.ts Updates expectations to match SSR path-key pinned module specifiers.
src/transforms/esm/specifier-resolver.ts Adds helper for cacheable specifier normalization (module-origin aware).
src/server/project-env/fetcher.ts Ensures required env fetch headers override optional caller headers; exports internals for testing.
src/server/project-env/fetcher.test.ts Adds regression test for authoritative env fetch headers behavior.
src/modules/server/module-server.test.ts Updates SSR nested module fetch assertions to match new pinning expectations.
src/server/services/rsc/endpoints/rsc-bundles.generated.ts Regenerates checked-in RSC client bundles from updated source.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/transforms/mdx/index.ts
Normalize protocol-relative and case-variant HTTP imports before dependency pinning and cache resolution so equivalent same-origin module URLs cannot bypass snapshot transport.
Thread the server-owned local-project signal through page, layout, and RSC MDX loading so pinned module paths can use the guarded local module-server fallback. Add caller-boundary regressions for each rendering path.
Copilot AI review requested due to automatic review settings August 3, 2026 12:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 31 out of 32 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings August 3, 2026 13:08
@kojiwakayama

Copy link
Copy Markdown
Contributor Author

Final review fix pushed in 64237b2.

Found and fixed a production blocker in the path-pinned MDX transport: /_vf_modules/_pins/<snapshot>/... imports reached ModuleFetcher with the transport prefix still attached, so hosted adapter lookup treated _pins/... as a project directory. The fetcher now validates the pin against the active snapshot, rejects malformed/mismatched paths before adapter access, and unwraps the transport path before normal resolution.

Regression coverage now includes matching, mismatched, and malformed path pins. The module-writer test server mock was also tightened to enforce the real server contract of exactly one pin transport.

Validation:

  • affected suite: 35 passed / 593 steps
  • changed-file format, lint, typecheck, and diff checks: pass
  • dependency/module boundary gates: pass
  • generated RSC bundle regeneration: byte-identical
  • deno task verify:quick: pass
  • synthetic merge with origin/main at f56afcd: focused suite and verify:quick pass

The only review thread is resolved/outdated. I did not approve or merge.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 33 out of 34 changed files in this pull request and generated no new comments.

Suppressed comments (3)

src/server/services/rsc/orchestrators/render-handler.test.ts:291

  • The test captures isLocalProject via args[11], which is brittle and easy to break if the loadModuleESM signature changes (or if an argument is inserted). Prefer an explicit parameter list so the assertion stays aligned with the call contract.
      mutableRenderer.loadModuleESM = ((...args: unknown[]) => {
        observedIsLocalProject = args[11];
        return Promise.resolve({ default: () => null });
      }) as typeof mdxRenderer.loadModuleESM;

src/rendering/page-rendering.test.ts:204

  • The test captures isLocalProject via args[11], which is brittle and can silently drift if the loadModuleESM parameter list changes. Use an explicit parameter list and read isLocalProject directly.
    let observedIsLocalProject: unknown;
    mutableRenderer.loadModuleESM = ((...args: unknown[]) => {
      observedIsLocalProject = args[11];
      return Promise.resolve({ default: () => null });
    }) as typeof mdxRenderer.loadModuleESM;

src/rendering/orchestrator/layout.test.ts:19

  • The test reads isLocalProject via a magic index (args[11]), which is brittle and obscures what is being asserted. Prefer an explicit parameter list so the capture stays correct if the signature changes.
    let observedIsLocalProject: unknown;
    mutableRenderer.loadModuleESM = ((...args: unknown[]) => {
      observedIsLocalProject = args[11];
      return Promise.resolve({ default: () => null });
    }) as typeof mdxRenderer.loadModuleESM;

@kojiwakayama

Copy link
Copy Markdown
Contributor Author

The remaining test-maintainability finding is fixed at exact head 5872f71 (parent 64237b2). All three fragile args[11] captures now use explicit named parameters, with assertions unchanged and no production behavior change. Exact-head changed-area coverage passes (16 tests / 401 steps), formatting, lint, typecheck, verify:quick, and diff checks pass. The conflict-free synthetic merge against main f56afcd passes the affected 3 tests / 16 steps plus verify:quick. Review threads: 0 unresolved. Confidence: 98%. Fresh hosted CI and merge-queue combined checks remain required.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 33 out of 34 changed files in this pull request and generated no new comments.

Suppressed comments (3)

src/server/services/rsc/orchestrators/render-handler.test.ts:291

  • This test hard-codes the loadModuleESM argument index (args[11]) to observe isLocalProject, which is brittle if the loadModuleESM signature changes. Prefer reading the last argument so the test tracks the contract without relying on a fixed positional index.
      mutableRenderer.loadModuleESM = (
        _compiledProgramCode,
        _adapter,

src/rendering/orchestrator/layout.test.ts:19

  • This test hard-codes the loadModuleESM argument index (args[11]) to observe isLocalProject, which is brittle if the loadModuleESM signature changes. Prefer reading the last argument so the test tracks the contract without relying on a fixed positional index.
    mutableRenderer.loadModuleESM = (
      _compiledProgramCode,
      _adapter,

src/rendering/page-rendering.test.ts:204

  • This test hard-codes the loadModuleESM argument index (args[11]) to observe isLocalProject, which is brittle if the loadModuleESM signature changes. Prefer reading the last argument so the test tracks the contract without relying on a fixed positional index.
    mutableRenderer.loadModuleESM = (
      _compiledProgramCode,
      _adapter,

Copilot AI review requested due to automatic review settings August 3, 2026 13:45
@kojiwakayama

Copy link
Copy Markdown
Contributor Author

Merge confidence: 94% for exact head 5872f71.\n\nReasoning: the current head has no unresolved review threads and local exact-head verification passed for the SSR/module loader, render orchestration, project env fetcher, RSC orchestrator, import-rewriter, specifier resolver, and MDX module-fetcher/writer paths changed by this PR. Verification run on the exact head included git diff --check, deno fmt/lint/check over all changed TS/TSX files, generate:manifests:check, and 15 targeted tests / 342 steps with 0 failures. I did not rerun the broad network-backed http-cache suite locally because this environment has known SOCKS/network fixture failures there; hosted CI remains the required gate before merge.

@kojiwakayama
kojiwakayama removed this pull request from the merge queue due to a manual request Aug 3, 2026
@kojiwakayama
kojiwakayama added this pull request to the merge queue Aug 3, 2026
@kojiwakayama
kojiwakayama removed this pull request from the merge queue due to a manual request Aug 3, 2026
The SSR pinned-module follow-up was green at its own head but dirty after main advanced. Merge current main and regenerate the RSC bundle endpoint so GitHub can validate the reviewed changes at the current base.

Constraint: GitHub marked the PR dirty after main advanced.

Rejected: Rebase the follow-up branch | merge preserves reviewed PR history while clearing the base state.

Confidence: high

Scope-risk: moderate

Directive: Regenerate src/server/services/rsc/endpoints/rsc-bundles.generated.ts after resolving runtime service changes.

Tested: deno fmt --check changed SSR/MDX/RSC files

Tested: deno lint changed SSR/MDX/RSC files

Tested: deno check changed SSR/MDX/RSC files

Tested: focused SSR/MDX/RSC/dev-server tests passed

Not-tested: Full repository pre-push suite for this branch after the merge
Copilot AI review requested due to automatic review settings August 3, 2026 18:35
@kojiwakayama

Copy link
Copy Markdown
Contributor Author

Updated this PR onto current main at 7e451d6a3.

What changed:

  • Merged latest main to clear the dirty base state.
  • Resolved the generated RSC bundle endpoint by rerunning deno task generate.
  • Removed a local test-created deno.lock loopback URL artifact before committing.

Verification on the resolved merge:

  • deno fmt --check on the changed SSR/MDX/RSC files passed.
  • deno lint on the changed SSR/MDX/RSC files passed.
  • deno check on the changed SSR/MDX/RSC files passed.
  • Focused SSR/MDX/RSC/dev-server tests passed, including the MDX renderer integration and RSC orchestrator suites.
  • git diff --check passed.

I am waiting for hosted checks on this exact head before assigning merge confidence or queueing.

The hosted coverage shard preloads schema setup before running the import-map preloader tests. That changes microtask timing enough for the capacity-race test to await an earlier load before resolving the newly admitted load, letting the admitted load hit its artificial timeout even though the admission contract already succeeded. Resolve the newly admitted load immediately after observing it so the test still proves capacity was not missed without depending on preload-specific scheduling.

Constraint: Hosted coverage runs with src/schemas/_test-setup.ts preload and parallel shard settings.

Rejected: Increase the artificial timeout | this would hide the timing dependency instead of removing it.

Confidence: high

Scope-risk: narrow

Tested: npx --yes deno@2.7.7 test --preload=src/schemas/_test-setup.ts --no-check --parallel --allow-all --unstable-worker-options --unstable-net src/modules/import-map/preloader.test.ts

Tested: npx --yes deno@2.7.7 test --no-check --allow-all src/rendering/page-rendering.test.ts

Tested: npx --yes deno@2.7.7 fmt --check src/modules/import-map/preloader.test.ts

Tested: npx --yes deno@2.7.7 lint src/modules/import-map/preloader.test.ts

Not-tested: Full repository pre-push suite, skipped because the branch already hit unrelated local parallel-suite flakes while the exact hosted failure now passes.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 39 out of 40 changed files in this pull request and generated no new comments.

Suppressed comments (2)

src/transforms/README.md:45

  • result is assigned but never used in this quick-start snippet, which can be confusing for readers. Consider either using the return value (e.g., showing how to consume the transformed ESM) or removing the binding and just awaiting the call.
const result = await transformToESM(code, {
  filename: "component.tsx",
  jsx: "react",
});

src/transforms/mdx/esm-module-loader/module-fetcher/index.ts:71

  • These new dependency-pin errors are defined locally with defineError(...). Veryfront’s error-handling pattern expects new slugs to live in the centralized error registry (so they are consistently exported, documented, and de-duplicated), then imported here. Consider moving this definition (and the companion dependency-pin-mismatch) to src/errors/error-registry/module.ts and importing the constants from #veryfront/errors.

Copilot AI review requested due to automatic review settings August 3, 2026 18:40
@kojiwakayama

Copy link
Copy Markdown
Contributor Author

Pushed e1a444c655aa9e189a7af6549eb201741974d13b to address the hosted coverage shard failure.

Root cause: under the hosted coverage command with src/schemas/_test-setup.ts preloaded, the import-map capacity-race test awaited the earlier admitted load before resolving the newly admitted third load. That made the new load vulnerable to the test-only artificial timeout even though the capacity retry contract had already been proven by observing the third loader.

Fix: resolve the newly admitted third load immediately after waitForLoadCount(loads, 3), then assert the earlier and queued results. This keeps the test asserting that capacity released during admission was not missed without depending on preload-specific microtask timing.

Local verification:

  • npx --yes deno@2.7.7 test --preload=src/schemas/_test-setup.ts --no-check --parallel --allow-all --unstable-worker-options --unstable-net src/modules/import-map/preloader.test.ts -> 47 steps, 0 failures.
  • Focused fix(ssr): preserve pinned module transport after #3290 #3332 transport/regression batch passed except for the known src/rendering/page-rendering.test.ts resource leak when run inside the broad batch.
  • npx --yes deno@2.7.7 test --no-check --allow-all src/rendering/page-rendering.test.ts -> 5 steps, 0 failures.
  • npx --yes deno@2.7.7 fmt --check src/modules/import-map/preloader.test.ts, lint, and git diff --check passed.

This is not a merge-confidence declaration yet. Hosted checks are still running on this exact head.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 39 out of 40 changed files in this pull request and generated no new comments.

Suppressed comments (1)

src/transforms/mdx/index.ts:75

  • loadModuleESM uses a default value (= {}) for optionsOrAdapter. When callers use the legacy positional signature and pass undefined for the adapter (e.g. loadModuleESM(code, undefined, projectId, ...)), the default parameter turns that undefined into {}, so context.adapter becomes truthy and the loader skips adapter auto-detection. This will later crash when the loader calls adapter methods (e.g. loadImportMap(projectDir, adapter)).

Use an undefined default for optionsOrAdapter and keep the optionsOrAdapter ?? {} fallback only in the options-object branch.

@kojiwakayama

Copy link
Copy Markdown
Contributor Author

Merge confidence for exact head e1a444c655aa9e189a7af6549eb201741974d13b: 93%.

Reasoning:

  • GitHub reports this exact head as merge-clean with no pending or failed hosted checks.
  • Active review-thread audit reports 0 unresolved threads.
  • The current head includes the main reconciliation plus the hosted coverage-shard stabilization for the import-map preloader capacity test.
  • Local verification reproduced the hosted preloader failure with the schema preload flags, then passed the same hosted-style command after the fix: 47 steps, 0 failures.
  • Focused pinned-transport verification passed; the only broad local batch issue was the known src/rendering/page-rendering.test.ts resource leak when combined with many suites, and that file passed in isolation.

Residual risk is moderate-low because this PR touches SSR/MDX module transport and import resolution paths, but review comments are resolved, targeted regressions cover the changed behavior, and the full hosted matrix is green at the exact head. --match-head-commit protects against queueing a stale head.

@kojiwakayama
kojiwakayama added this pull request to the merge queue Aug 3, 2026
@kojiwakayama

Copy link
Copy Markdown
Contributor Author

Merge confidence: 93% for exact head e1a444c655aa9e189a7af6549eb201741974d13b.

Reasoning:

  • GitHub reports this exact head as CLEAN with hosted checks terminal green: format, lint, typecheck, CodeQL/Analyze, coverage shards/gate, unit, integration, RSC browser e2e, binary e2e, npm install smoke, sentry runtime packages, tests-proxy-binary, and CLA.
  • GraphQL review-thread audit reports 13 total threads and 0 unresolved.
  • The current branch is already up to date with main, and the prior pinned-module transport fixes remain intact after the latest hosted rerun. The earlier shard-1 failure is cleared on the fresh exact-head run.
  • Local worktree verification confirmed the branch was merge-clean against origin/main, with no conflict resolution needed at the current head.

Residual risk is moderate-low because the PR repairs SSR/pinned module transport behavior, which is cross-cutting but covered by the hosted matrix and review-thread closure. This exceeds the 90% threshold and applies only to the exact SHA above.

Regenerated rsc-bundles.generated.ts from merged sources and unioned
the module-writer test imports from both sides.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 39 out of 40 changed files in this pull request and generated no new comments.

Suppressed comments (1)

src/server/project-env/fetcher.ts:287

  • projectEnvFetcherInternals is exported as a test-only surface, but its name does not match the existing in-repo convention for test-only exports (typically __*ForTests, e.g. src/transforms/esm/http-cache.ts:267-270 exports __injectCachesForTests). Using the established naming pattern makes it harder to accidentally depend on this from production code and keeps internal APIs visually distinct.
/**
 * Test-only access to the privileged fetch helper. Never import this outside
 * `fetcher.test.ts`.
 *
 * The header-authority regression it guards (authoritative `Authorization`/
 * `Accept` must be set after merging optional caller headers) is unobservable
 * through `fetchProjectEnvVars`: the public path only ever passes a benign
 * `x-project-slug` header, so a reintroduced spread-order bug would not change
 * the public function's behavior in a test.
 *
 * @internal
 */
export const projectEnvFetcherInternals = {
  fetchEnvironmentVariables,
} as const;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants